package cn.livingCloud.entity.content;

import cn.livingCloud.context.BeanProvider;
import cn.livingCloud.repository.TextReplyContentMapper;
import cn.livingCloud.utils.UuidGenerator;
import cn.livingCloud.wechat.protocol.req.AbstractReqMsg;
import cn.livingCloud.wechat.protocol.resp.AbstractRespMsg;
import cn.livingCloud.wechat.protocol.resp.TextRespMsg;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 唐旭 on 2015/12/8.
 */
public class TextReplyContent extends TextRespMsg implements AbstractReplyContent {
    private transient TextReplyContentMapper contentMapper = BeanProvider.getBean(TextReplyContentMapper.class);

    private String uuid = UuidGenerator.generate();
    private String rule_id;

    public TextReplyContent() {
    }

    public TextReplyContent(AbstractReqMsg reqMsg) {
        super(reqMsg);
    }

    @Override
    public String getUuid() {
        return uuid;
    }

    public TextReplyContent setUuid(String uuid) {
        this.uuid = uuid;
        return this;
    }

    public String getRule_id() {
        return rule_id;
    }

    public TextReplyContent setRule_id(String rule_id) {
        this.rule_id = rule_id;
        return this;
    }

    @Override
    public AbstractRespMsg toAbstractRespMsg() {
        return this;
    }

    @Override
    public void delete() {
        contentMapper.delete(uuid);
    }

    @Override
    public List<String> getReplyContent() {
        List<String> stringList = new ArrayList<>();
        stringList.add(getContent());
        return stringList;
    }

    @Override
    public void setContent(List<String> result) {
        this.setContent(result.get(0));
    }
}
